﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <title>任务管理</title>
    <link href="/CSS/bootstrap3.3.5/css/bootstrap.css" rel="stylesheet" type="text/css" />
    <link href="/JqueryPlug/zTree_v3/css/zTreeStyle/zTreeStyle.css" rel="stylesheet" />
    <link href="/CSS/font-awesome-4.3.0/css/font-awesome.css?v=4.3.0" rel="stylesheet">
    <link href="/CSS/V3/animate.css" rel="stylesheet">
    <link href="/CSS/V3/style.css?v=2.2.0" rel="stylesheet">
    <link href="/CSS/V3/BaseClassV3.css" rel="stylesheet" />
    <script src="/Scripts/jquery-1.11.2.min.js"></script>
    <script src="/CSS/bootstrap3.3.5/js/bootstrap.js"></script>
    <script src="/JqueryPlug/laypage/laypage.js"></script>
    <script src="/Scripts/avalon.js"></script>
    <script src="/Scripts/jquery-migrate-1.1.0.min.js"></script>
    <script src="/Scripts/SZHLCommon.js?jsver=5"></script>
    <script src="/JqueryPlug/zTree_v3/js/jquery.ztree.core-3.5.js"></script>
    <script src="/JqueryPlug/zTree_v3/js/jquery.ztree.excheck-3.5.min.js"></script>
    <style>
        img {
            max-width: 100%;
        }
    </style>
    <script>
        var zNodes = null;
        var zTreeObj = null;
        var model = avalon.define({
            $id: "APP_RCTX",
            username: ComFunJS.getnowuser(),
            menutype: "-1",
            CommonData: [],
            type: "0",
            seltype: "0",
            peo: "0",
            selpeo: "0",
            content: "",
            selcontent: "",
            addRCTX: function () {
                parent.ComFunJS.winviewform("/View/APPBaseView/APP_ADD_WF.html?FormCode=RCTX&FrameName=frameRCTX", "添加数据", "1000", "");
            },
            ModityRCTX: function (Id) {
                parent.ComFunJS.winviewform("/View/APPBaseView/APP_ADD_WF.html?FormCode=RCTX&FrameName=frameRCTX&ID=" + Id, "编辑数据", "1000", "");
            },
            deltx: function (el, event) {
                event.stopPropagation();
                parent.ComFunJS.winconfirm('你确定要删除此任务吗？', function () {
                    $.getJSON("/API/FTAPI.ashx?Action=DELRWDB", { P1: el.ID }, function (resultData) {
                        if (resultData.ErrorMsg == "") {
                            model.CommonData.remove(el);
                            parent.ComFunJS.winsuccess('删除成功');
                        }

                    });
                }, function () { })
            },
            addZRW: function (ID) {
                parent.ComFunJS.winviewform("/View/APPBaseView/APP_ADD_WF.html?FormCode=RCTX&FrameName=frameRCTX&TopID=" + ID, "添加数据", "1000", "");
            },
            viewZRW: function (ID) {
                parent.ComFunJS.winviewform("/ViewV3/APPBaseView/APP_ZRW.html?ID=" + ID + "&pageType=view&r=" + Math.random(), "子任务", "1000", "");
            },
            addalert: function (el) {
                var urs = '';
                if (el.RWCYR) {
                    if (el.RWCYR.indexOf(el.RWFZR) != -1) {
                        urs = el.RWCYR;
                    }
                    else {
                        urs = el.RWFZR + ',' + el.RWCYR;
                    }
                }
                else {
                    urs = el.RWFZR;
                }
                parent.ComFunJS.winviewform("/View/APPBaseView/APP_ADD_WF.html?FormCode=TXSX&ausername=" + urs + "&acode=dbsx&aid=" + el.ID, "添加提醒", "1000", "");
            },
            enterDB: function (el, dom) {
                if ($(dom).parent().find('.dbztinfo').is(":hidden")) {
                    $('.dbztinfo').hide('fast');
                    $(dom).parent().find('.dbztinfo').show('fast')
                } else {
                    $(dom).parent().find('.dbztinfo').hide('fast')
                }

            },
            inputevent: function (event) { //输入框事件
                event.stopPropagation();
            },
            addPL: function (el, dom, event) {
                if (event) {
                    event.stopPropagation();
                }
                var content = $(dom).parent().parent().find(".plnr").val();
                if (content == "") {
                    parent.ComFunJS.winwarning("请输入批注内容");
                } else {
                    $.post('/API/FTAPI.ashx?Action=ADDCOMENT', { "P1": content, "MsgType": "RCTX", "MsgLYID": el.ID }, function (result) {
                        var result = $.parseJSON(result);
                        if (result.ErrorMsg == "") {
                            el.PLList.push(result.Result)
                            $(dom).parent().parent().find(".plnr").val("")
                        }
                    })
                }

            },
            completeDB: function (el, event, dom) {//修改待办状态
                event.stopPropagation();
                if ($(dom).hasClass("icon-gouxuan")) {
                    $(dom).removeClass("icon-gouxuan");
                    $(dom).addClass("icon-weigouxuan");
                }
                else {
                    $(dom).removeClass("icon-weigouxuan");
                    $(dom).addClass("icon-gouxuan");
                }
                var ISComplete = $(dom).hasClass("icon-gouxuan") ? "1" : "0";
                if (ISComplete == "1") {

                    $(dom).parent().parent().parent().css({ "background-color": "aliceblue" });
                } else {
                    $(dom).parent().parent().parent().css({ "background-color": "transparent" });
                }
                $.getJSON('/API/FTAPI.ashx?Action=COMPLETERCTX', { "P1": el.ID, "P2": ISComplete }, function (result) {
                    if (result.ErrorMsg == "") {
                        parent.ComFunJS.winsuccess("操作成功");
                    }
                })
            },
            //键盘提交事件
            jptj: function (el, dom, event) {
                if (event.ctrlKey && (event.keyCode == 13 || event.keyCode == 10)) {

                    model.addPL(el, dom);

                }
            },
            menutype: "-1",
            GetDBDataList: function () {

                $.getJSON("/API/FTAPI.ashx?Action=GETRCTXDATA_PAGE", { P1: model.type, p: 1, P2: model.peo, Content: model.content, b: model.menutype, QUSER: model.queryuser }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        model.CommonData.clear();
                        model.CommonData = resultData.Result;
                        model.seltype = model.type;
                        model.selpeo = model.peo;
                        model.selcontent = model.content;
                        if (parseInt(resultData.Result1) > 0) {
                            laypage({
                                cont: 'pageDiv', //容器。值支持id名、原生dom对象，jquery对象。
                                pages: Math.ceil(parseInt(resultData.Result1) * 1.0 / 8), //通过后台拿到的总页数
                                curr: 1, //初始化当前页
                                jump: function (e) { //触发分页后的回调
                                    if (model.seltype != model.type || model.selpeo != model.peo || model.selcontent != model.content) {
                                        e.curr = 1;
                                    }
                                    $.getJSON('/API/FTAPI.ashx?Action=GETRCTXDATA_PAGE', { P1: model.type, p: e.curr, P2: model.peo, Content: model.content, b: model.menutype, QUSER: model.queryuser }, function (resultData) {

                                        model.CommonData.clear();
                                        model.CommonData = resultData.Result;
                                        model.seltype = model.type;
                                        model.selpeo = model.peo;
                                        model.selcontent = model.content;
                                    })
                                }
                            });
                        }
                    } else {
                        parent.ComFunJS.winwarning(resultData.ErrorMsg);
                    }

                });
            },
            LB: function () {
                model.type = $(this).attr("val");
                if ($(this).hasClass("btn-primary")) {
                    model.GetDBDataList()
                }
                else {
                    $(".leibie").removeClass("btn-primary");
                    $(".leibie").addClass("btn-white");
                    $(this).removeClass("btn-white");
                    $(this).addClass("btn-primary");
                    model.GetDBDataList()
                }
            },
            SS: function () {
                model.peo = $(this).attr("val");
                if ($(this).hasClass("btn-primary")) {
                    model.GetDBDataList()
                }
                else {
                    $(".suoshu").removeClass("btn-primary");
                    $(".suoshu").addClass("btn-white");
                    $(this).removeClass("btn-white");
                    $(this).addClass("btn-primary");
                    model.GetDBDataList()
                }
            },
            YC: function () {
                var obj = $(this).parent().parent().find(".social-footer");
                if (obj.is(":hidden")) {
                    obj.show();
                }
                else {
                    obj.hide();
                }
            },
            queryuser: ComFunJS.getnowuser(),
            username: ComFunJS.getnowuser(),
            fnqueryuser: function (item) {
                if (item) {
                    model.queryuser = item;
                    model.CommonData.clear();
                    model.GetDBDataList();
                }

            },
            //关注用户列表
            GetGuanZhuList: function () {
                $.getJSON('/API/FTAPI.ashx?Action=GETGUANZHULIST', function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        model.GuanZhuList = resultData.Result;
                    }
                })
            },
            GuanZhuData: function () {
                var userNames = "";
                if (model.GuanZhuList) {
                    model.GuanZhuList.forEach(function (val) {
                        userNames += val.BGZUser + ",";
                    })
                }
                if (userNames) {
                    userNames = userNames.substring(0, userNames.length - 1);
                }
                model.fnqueryuser(userNames);
            },
            IsShowTR: false,
            getMenu: function () {
                var setting = {
                    data: {
                        simpleData: {
                            enable: true,
                            idKey: "id",
                            pIdKey: "pId",
                            rootPId: 0
                        }
                    },
                    view: {
                        showLine: false
                    },
                    callback: {
                        onClick: model.zTreeOnClick
                    }
                };
                $.ajax({
                    type: "GET",
                    url: "/API/SZHLAPI.ashx",
                    dataType: "html",
                    data: { "Action": "GETALLBMUSERLIST" },
                    success: function (msg) {
                        if (JSON.parse(msg).Result) {
                            model.IsShowTR = true;
                        }
                        zTreeObj = $.fn.zTree.init($("#tree"), setting, eval(JSON.parse(msg).Result));
                    }
                });
            },
            zTreeOnClick: function (event, treeId, treeNode) {
                model.queryuser = "";
                model.CommonData.clear();
                if (treeNode.isUser) {
                    model.queryuser = treeNode.id;
                    model.GetDBDataList();
                } else {
                    parent.ComFunJS.winwarning("请选择具体的人员查看任务列表");
                    return;
                }
            },
            ComGRDB: function (el, event, dom) {
                event.stopPropagation();
                if ($(dom).hasClass("icon-gouxuan")) {
                    $(dom).removeClass("icon-gouxuan");
                    $(dom).addClass("icon-weigouxuan");
                }
                else {
                    $(dom).removeClass("icon-weigouxuan");
                    $(dom).addClass("icon-gouxuan");
                }
                var ISComplete = $(dom).hasClass("icon-gouxuan") ? "1" : "0";
                if (ISComplete == "1") {

                    $(dom).parent().parent().parent().parent().css({ "background-color": "aliceblue" });
                } else {
                    $(dom).parent().parent().parent().parent().css({ "background-color": "transparent" });
                }
                $.getJSON('/API/FTAPI.ashx?Action=COMGRRCTX', { "P1": el.ID, P2: ISComplete }, function (result) {
                    if (result.ErrorMsg == "") {
                        parent.ComFunJS.winsuccess("操作成功");
                    }
                })
            }, ShowFile: function (Id, event) {
                event.stopPropagation();
                $.getJSON('/API/FTAPI.ashx?Action=GETFILEINFO', { P1: Id }, function (resultData) {
                    window.open(resultData.Result2);
                    
                })
            }
        })
        avalon.ready(function () {
            ComFunJS.initsetajax();
            model.GetDBDataList();
            model.getMenu();
            model.GetGuanZhuList();
        })

        function rwzt(str) {
            if (str == "0") {
                return '<label class="label label-danger" style="margin-right:10px">正在进行</label>';
            }
            else if (str == "1") {
                return '<label class="label label-default" style="margin-right:10px">已结束</label>';
            }
        }
    </script>

</head>
<body class="gray-bg" ms-controller="APP_RCTX">

    <div class="wrapper wrapper-content  animated fadeInRight">
        <div class="row">
            <div class="col-sm-3">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <div class="file-manager">
                            <div class="hr-line-dashed"></div>
                            <button class="btn btn-primary btn-block" ms-click="addRCTX()">添加任务</button>
                            <div class="hr-line-dashed"></div>
                            <h4>状态</h4>
                            <button class="btn btn-white btn-sm leibie" type="button" val="" ms-click="LB()">全部</button>
                            <button class="btn btn-primary btn-sm leibie" type="button" val="0" ms-click="LB()">正在进行</button>
                            <button class="btn btn-white btn-sm leibie" type="button" val="1" ms-click="LB()">已结束</button>
                            <div class="hr-line-dashed"></div>
                            <h4 class="tag-title"><a href="APP_RWDB.html">我的任务</a></h4>
                            <h4 class="tag-title" ms-if="GuanZhuList.size()>0" ms-click="GuanZhuData()"><a>我的关注</a></h4>
                            <ul class="tag-list" style="padding: 0">
                                <li ms-repeat-item="GuanZhuList" ms-click="fnqueryuser(item.BGZUser)">
                                    <button class="btn btn-outline " style="margin-right:5px;" ms-class-1="btn-default:item.BGZUser!=queryuser" ms-class-2="btn-warning:item.BGZUser== queryuser">{{ComFunJS.convertuser(item.BGZUser)}}</button>
                                </li>
                            </ul>
                            <div class="clearfix"></div>
                            <h4 class="tag-title" ms-if="model.IsShowTR">他人任务</h4>
                            <ul id="tree" ms-if="model.IsShowTR" class="ztree"></ul>
                            <div class="clearfix"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-9">
                <div class="box" style="margin-bottom:3px;">

                    <div class="pull-right mail-search">
                        <div class="input-group">
                            <input type="text" class="form-control input-sm" name="search" ms-duplex="content" placeholder="输入任务内容查询">
                            <div class="input-group-btn">
                                <button type="submit" class="btn btn-sm btn-primary" ms-click="GetDBDataList()">
                                    搜索
                                </button>
                            </div>
                        </div>
                    </div>
                    <h2>
                        任务管理
                    </h2>
                    <div class="mail-tools tooltip-demo m-t-md">

                        <div class="btn-group pull-right">
                            <div id="pageDiv" class="text-center"></div>
                        </div>
                        <div class="input-group-btn">
                            <button type="button" style="margin-left:0" class="btn btn-primary suoshu" val="0" ms-click="SS()">全部</button>
                            <button type="button" class="btn btn-white suoshu" val="1" ms-click="SS()">创建的</button>
                            <button type="button" class="btn btn-white suoshu" val="2" ms-click="SS()">负责的</button>
                            <button type="button" class="btn btn-white suoshu" val="3" ms-click="SS()">参与的</button>
                        </div>
                    </div>
                </div>


                <div class="social-feed-separated" style="margin-top:10px">

                    <div class="social-feed-box" ms-repeat-el="CommonData" style="border:0;border-bottom: 1px solid #e7eaec;">

                        <div class="pull-right social-action dropdown" style="margin-bottom:0px;">
                            <a class=" btn btn-primary btn-xs btntool" ms-if="el.ISGB"><i ms-on-click="completeDB(el,event,this)" class="iconfont icon-weigouxuan" style="font-size: 12px; margin-right: 3px; color:white"></i>关闭任务</a>
                            <a class=" btn btn-primary btn-xs btntool" ms-attr-dataid="el.ID" ms-attr-dbnr="el.Name" ms-attr-leibie="el.LeiBie" ms-attr-txdate="el.TXTime" ms-click="ModityRCTX(el.ID)" ms-attr-txr="el.TXUser" ms-if="el.CRUser==username"><i class="fa fa-pencil"></i> 编辑 </a>
                            <a class="btn btn-danger btn-xs btntool" style="margin-right:15px" ms-if="el.CRUser==username" ms-click="deltx(el,event)"><i class="fa fa-trash-o"></i> 删除 </a>
                            <a class="btn btn-white btn-xs" ms-click="YC()"><i class="fa fa-angle-down"></i> </a>
                        </div>

                        <div class="social-avatar" style="line-height: 23px;">
                            <p>
                                <label class="label label-danger" style="margin-right:10px" ms-if="ComFunJS.daysBetween(ComFunJS.getnowdate('yyyy-mm-dd'), el.CRDate.substring(0,10))<=0&&el.RWStatus=='0'">{{el.Status==1?"已完成":"已过期"}}</label>
                                <label ms-if="ComFunJS.daysBetween(ComFunJS.getnowdate('yyyy-mm-dd'), el.CRDate.substring(0,10))>0||el.RWStatus!='0'">{{el.Status==1&&el.RWStatus=='0'?"已完成":rwzt(el.RWStatus)|html}}</label>

                                <label class="label label-danger" style="margin-right:10px" ms-if="el.LeiBie=='重要'">{{el.LeiBie}}</label>
                                <a class=" btn btn-primary btn-xs btntool " ms-if="($.inArray(username, el.RWCYR.split(','))>-1||$.inArray(username, el.RWFZR.split(','))>-1)&&el.CRUser!=username&&el.Status!=1&&el.RWStatus=='0'"><i ms-on-click="ComGRDB(el,event,this)" class="iconfont icon-weigouxuan" style="font-size: 12px; margin-right: 3px;color:white"></i>完成任务</a>
                            </p>
                        </div>

                        <div style="padding:0px 15px 0 15px">
                            <p>
                                {{el.RWTitle|html}}
                            </p>
                        </div>

                        <div class="social-body" style=" padding-top: 0px; padding-bottom: 0px; ">

                            <p class="jnperson">
                                <span>创建人：<span class="text-success">{{ComFunJS.convertuser(el.CRUser)}}</span></span>
                                <span>负责人：</span><span class="text-success"><span>{{ComFunJS.convertuser(el.RWFZR)}}</span></span>
                                <span style=" padding-left:10px;" ms-if="el.RWCYR.length>0">参与人：</span>
                                <span class="text-success"><span style="margin-right:10px" ms-repeat-user="el.RWCYR.split(',')">{{ComFunJS.convertuser(user) }}</span></span>
                                <small class="pull-right btntool">
                                    <span class="text-danger">{{el.RWJZDate|date("yyyy年MM月dd日")}}</span>
                                    <a style="margin-left:10px;" ms-click="addalert(el)">添加提醒</a>
                                    <a ms-if="el.RWStatus=='0'" ms-click="addZRW(el.ID)"> 添加子任务 </a>
                                </small>
                            </p>
                            <p>
                                <span ms-if="el.PLList.size()>0" style="margin-right:5px;">评论数： {{el.PLList.size()+(el.RCTXStatus.length>0? el.RCTXStatus.size():0)}}个 </span>
                                <span ms-if="el.ZRWCount>0">
                                    <span>子任务：</span><span><span>{{el.ZRWCount}}个</span></span>
                                    <a class=" btn btn-primary btn-xs" ms-if="el.ZRWCount>0" ms-click="viewZRW(el.ID)"> 查看 </a>
                                </span>
                            </p>
                            <p>
                                <label ms-if="el.FileList.length>0"> 附件：</label><span ms-repeat-files="el.FileList">
    <a style="margin-left:10px" target="_blank" download="filename" ms-attr-href="'/View/Common/DownLoadFile.aspx?MD5='+files.FileMD5">{{files.Name+'.'+files.FileExtendName}}</a>
    <a style="margin-left:5px; color:#ff6a00" ms-if="files.FileExtendName=='doc'||files.FileExtendName=='docx'||files.FileExtendName=='pdf'" ms-click="ShowFile(files.ID,event)">预览</a>
</span>

                            </p>
                        </div>
                        <div class="social-footer" style="display:none">
                            <div class="social-comment" ms-repeat-item="el.RCTXStatus">
                                <span class="pull-left">
                                    <img alt="image" ms-attr-src="'/Upload/TX/'+item.rwUser+'.jpg'" onerror="javascript: this.src = '/images/TX/default.png'">
                                </span>
                                <div class="media-body">
                                    <span style="color: #3085DB;">
                                        {{item.rwUserName}}
                                    </span>完成任务
                                    <br /> -
                                    <small class="text-muted">{{item.CRDate|date("MM月dd日 HH:mm")}}</small>
                                </div>
                            </div>
                            <div class="social-comment" ms-repeat-item="el.PLList">
                                <span class="pull-left">
                                    <img alt="image" ms-attr-src="'/Upload/TX/'+item.CRUser+'.jpg'" onerror="javascript: this.src = '/images/TX/default.png'">
                                </span>
                                <div class="media-body">
                                    <span style="color: #3085DB;">
                                        {{item.CRUserName}}
                                    </span> {{item.MSGContent|html}}
                                    <br /> -
                                    <small class="text-muted">{{item.CRDate|date("MM月dd日 HH:mm")}}</small>
                                </div>
                            </div>

                            <div class="social-comment">
                                <span class="pull-left">
                                    <img alt="image" ms-attr-src="'/Upload/TX/'+username+'.jpg'" onerror="javascript: this.src = '/images/TX/default.png'">
                                </span>
                                <div class="media-body">
                                    <div class="input-group">
                                        <input type="text" class="form-control plnr" placeholder="填写内容(按Ctrl+Enter直接提交)" ms-keypress="jptj(el,this,event)" />
                                        <span class="input-group-btn">
                                            <button type="button" class="btn btn btn-primary " ms-on-click="addPL(el,this,event)">  发表</button>
                                        </span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

</body>
</html>
